//
//  NianFeilongViewController.m
//  Music
//
//  Created by dllo on 16/6/6.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "NianFeilongViewController.h"
#import "YFLdetailViewController.h"
#import "Mytools.h"
@interface NianFeilongViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,retain)UITableView *mainTableView;
@property(nonatomic,retain) NSArray *souceArray;


@end

@implementation NianFeilongViewController
-(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.souceArray =[NSMutableArray array];

    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
   
     self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    [self.navigationController.navigationBar setBarTintColor:[UIColor redColor]];
    
    self.navigationItem.title = @"歌手";
    
    self.view.backgroundColor =[UIColor colorWithRed:0.92 green:0.29 blue:0.29 alpha:1.00];
    
    
    self.souceArray = @[@"TOP100",@"最近很红",@"华语男歌手",@"华语女歌手",@"华语组合",@"日本男歌手",@"日本女歌手",@"日本组合",@"韩国男歌手",@"韩国女歌手",@"韩国组合",@"欧美男歌手",@"欧美女歌手",@"欧美组合"];
    
    //创建tableView
    [self creatMainTableView];
    //网络获取
    //[self getMainNetData];
}



-(void)creatMainTableView
{
    
    self.mainTableView =[[UITableView alloc]initWithFrame:CGRectMake(0, 0, Screenwidth, Screenheight-49) style:(UITableViewStylePlain)];
    self.mainTableView.delegate =self;
    self.mainTableView.dataSource =self;
    
    [self.view addSubview:_mainTableView];
    
    [self.mainTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    
    
    
    
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.souceArray.count;
}




-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell =[self.mainTableView dequeueReusableCellWithIdentifier:@"cell"];
   // cell.backgroundColor =[UIColor cyanColor];
    cell.textLabel.text = [self.souceArray objectAtIndex:indexPath.row];
    return cell;
    
    
}


-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 60;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   // NSLog(@"%ld",indexPath.row);
    YFLdetailViewController *detailVC =[[YFLdetailViewController alloc]init];
    detailVC.titleStr = [self.souceArray objectAtIndex:indexPath.row];
    detailVC.integer = indexPath.row+1;
    [self.navigationController pushViewController:detailVC animated:YES];
    
    
    
    
}

//网络获取数据


-(void)getMainNetData
{
    
    
    NSString *string = @"http://url.cn/28znhDx";
    
    [MyTools getNetWithUrl:string body:nil header:nil response:LHQJSON success:^(id result) {
       // NSLog(@"%@",result);
        
        NSDictionary *dictionary =(NSDictionary *)result;
        NSArray *array =[dictionary objectForKey:@"data"];
        
        for (NSDictionary *dic in array) {
            //NSLog(@"==================%@",dic);
            NSArray *arr =[dic objectForKey:@"singerClassifyGroup"];
            //NSLog(@"==================%@",arr);
            for (NSDictionary *diction in arr) {
                self.souceArray =[diction objectForKey:@"itemName"];
                
               
                
               
                NSLog(@"=============%@",self.souceArray);
               
            }
           
        }
              [self creatMainTableView];
        
    } failure:^(NSError *error) {
        NSLog(@"------------%@",error);
    }];
    
    
    
    
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
